<?php
/* @var $this ShiftController */

$this->pageTitle=Yii::app()->name . ' - Team Shifts';
$this->breadcrumbs=array(
	'Shifts'=>array('/shift/'),
	'Team Shifts',
);

//date processing
$week_start = new DateTime();
$week_start->setTimeZone(new DateTimeZone("America/Costa_Rica"));
$week_start->setISODate($year,$week);	
$monday = $week_start->format('Y-m-d');
$sunday = date('Y-m-d',  strToTime('next Sunday '.$week_start->format('Y-m-d')));
?>

<h1>Team Shifts</h1>

<p>

<?php

echo "<center>";
?>
<h3>Viewing Week <?php echo $week; ?> -  <?php echo $year; ?>   </h3>

From <?php echo $monday;?> thru <?php echo $sunday;?>
<br>

	<?php 
	echo CHtml::link('<-Prev Week', 
					 Yii::app()->createUrl('/shift/team_shifts' , 
										   array('week'=> ($week!=1)? $week-1 : 52, 
											     'year'=> ($week!=1)? $year : $year-1)), 
					 array('title' => 'Previous Week','style'=>'color:#339900;')
				); 	
	?>
	
	&nbsp | &nbsp
	
	<?php
	echo CHtml::link('Next Week->', 
					 Yii::app()->createUrl('/shift/team_shifts' , 
										   array('week'=> ($week!=52)? $week+1 : 1, 
												 'year'=>($week!=52)? $year : $year+1)), 
					 array('title' => 'Next Week','style'=>'color:#339900;')
				); 	
	?>


<?php
echo "</center>";

$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'id',
	'dataProvider'=>$this->getWeekSchedulesGrid(Yii::app()->user->team_id,$week,$year),
	//'summaryText' => '',
	'enableSorting' => false,
	'columns'=>array(
		/*
		array(
			'name'=>'batch',
			'header'=>'Batch#',
			'value'=>'$data[\'batch\']',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),
		), */
		//'iduser',
		array(
			'name'  => 'User',
			'type'  => 'raw',
			'value'=>'$data[\'username\']',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),									  
		),
		array(
			'name'  => 'Monday',
			'type'  => 'raw',
			'value'=>'$data[\'monday\']',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),									  
		),		
		//'mondayDate',
		array(
			'name'  => 'Tuesday',
			'type'  => 'raw',
			'value'=>'$data[\'tuesday\']',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),									  
		),	
		//'tuesdayDate',
		array(
			'name'  => 'Wednesday',
			'type'  => 'raw',
			'value'=>'$data[\'wednesday\']',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),									  
		),	
		//'wednesdayDate',
		array(
			'name'  => 'Thursday',
			'type'  => 'raw',
			'value'=>'$data[\'thursday\']',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),									  
		),	
		//'thursdayDate',
		array(
			'name'  => 'Friday',
			'type'  => 'raw',
			'value'=>'$data[\'friday\']',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),									  
		),	
		//'fridayDate',
		array(
			'name'  => 'Saturday',
			'type'  => 'raw',
			'value'=>'$data[\'saturday\']',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),									  
		),	
		//'saturdayDate',
		array(
			'name'  => 'Sunday',
			'type'  => 'raw',
			'value'=>'$data[\'sunday\']',
			'htmlOptions' => array(
								'style' => 'width:40px; text-align:center;',
							 ),									  
		),	
		//'sundayDate',
	),
)); ?>

<i>
* = Qshift Swap
<br>
** = Shift Change

